class CreateComments < ActiveRecord::Migration
  def self.up
    create_table :comments do |t|
      t.column :id , :int
      t.column :user_id , :integer, :null=>false
      t.column :paper_id , :integer, :null=>false
      t.column :content , :text, :null=>false
      t.column :modify_time, :datetime, :null=>false
    end
      execute "alter table comments add constraint fk_comment_users
              foreign key (user_id) references users(id)"
      execute "alter table comments add constraint fk_comment_papers
                foreign key (paper_id) references papers(id) on delete cascade"
    
  end

  def self.down
    drop_table :comments
  end
end
